#!/bin/bash
###
 # @Author: xubing
 # @Date: 2020-12-24 14:43:33
 # @LastEditTime: 2020-12-24 15:06:58
 # @LastEditors: Please set LastEditors
 # @Description: In User Settings Edit
 # @FilePath: /test_fswatch/fswatch_rsync.sh
### 


local_dir="test_fswatch"  #本地与与远程文件夹命名一致，不一致会有问题。
remote_user="xubing" #同步的远程用户名
remote_ip="192.168.40.43" # 远程ip地址
remote_base_dir="/Users/xubing/Desktop/" #远程目录

fswatch -o  $local_dir | xargs -n1 -I{} rsync -avPu --delete $local_dir --exclude .git --exclude __pycache__ --exclude .log --exclude .idea $remote_user@$remote_ip:$remote_base_dir 

# 如有多个，加 & 继续往下复制，如下
# fswatch -o  $local_dir | xargs -n1 -I{} rsync -avPu --delete $local_dir --exclude .git --exclude __pycache__ --exclude .log --exclude .idea $remote_user@$remote_ip:$remote_base_dir  &
# fswatch -o $local_dir  | xargs -n1 -I{} rsync -avPu --delete $local_dir --exclude .git --exclude __pycache__ --exclude .log --exclude .idea xb@192.168.20.5:/home/AI_lab/xb/mirror_2020/

